import torch

#创建一维向量

tensor= torch.tensor([1,2,3])
x=torch.randn(1,3)
print("输出维度",x[0,1])
print(tensor)
print(x)
import numpy as np
np_array=np.array([1,2,3])
tensor=torch.from_numpy(np_array)
print(tensor)

#创建二维向量

tensor_2d=torch.tensor(
[[-9,4,2,5,7],[3,0,12,8,6],[1,23,-6,45,2],[22,3,-1,72,6]
]
)
print("tensor_2d",tensor_2d)
print(tensor_2d.shape)

#创建多维向量

tensor_3d=torch.stack([tensor_2d,tensor_2d+10,tensor_2d-5])
print("3D Tensor (Cube):\n",tensor_3d)
print('shape',tensor_3d.shape)

tensor_4d=torch.stack([tensor_3d,tensor_3d+100])
print("4D Tensor (Cube):\n",tensor_4d)
print('shape',tensor_4d.shape)

tensor_5d=torch.stack([tensor_4d,tensor_4d+1000])
print("5D Tensor (Cube):\n",tensor_5d)
print('shape',tensor_5d.shape)


